package com.web.exiaodao.remote.controller;
import java.util.Map;
import java.util.List;

import com.web.webstart.base.util.jpa.WebUitl;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;

import com.web.webstart.base.constant.XaConstant;
import com.web.webstart.base.controller.BaseController;
import com.web.webstart.base.exception.BusinessException;
import com.web.webstart.base.util.result.XaResult;
import com.web.exiaodao.remote.service.ApiTaskTableService;
import com.web.exiaodao.remote.vo.TaskTableVo;

/**
 * @Title: ApiTaskTableController.java
 * @Package com.web.exiaodao.remote.controller
 * @Description: 签到-任务表信息接口
 * @author zhanglin
 * @date 2015年3月23日 下午1:00:00
 * @version V1.0
 */
@Api(value = "TaskTable", description = "签到-任务表接口", position = 10)
@Controller
@RequestMapping("/api/taskTable")
public class ApiTaskTableController extends BaseController {

	private static final Logger LOGGER = Logger.getLogger(ApiTaskTableController.class);

	@Autowired
	private ApiTaskTableService taskTableService;
	
	/**
	 * @Title: findTaskTableList
	 * @Description: 查询所有签到-任务表信息
	 * @return    
	 */
	@ApiOperation(value="查询所有签到-任务表",notes="查询所有签到-任务表信息,当返回的code=1时，取出object进行显示,存放为数组对象")
	@ResponseBody
	@RequestMapping(value="findTaskTableList",method=RequestMethod.POST)
	public XaResult<List<TaskTableVo>> findTaskTableList(
		@ApiParam("页号,字段名:nextPage,默认0,从第0页开始") @RequestParam(defaultValue = "0") Integer nextPage,
		@ApiParam("页长,字段名:pageSize,默认10") @RequestParam(defaultValue = "10") Integer pageSize
	) throws BusinessException{
		Pageable pageable = WebUitl.buildPageRequest(nextPage, pageSize, "[{property:'createTime',direction:'DESC'}]");
		Map<String , Object> filterParams =  WebUitl.getParametersStartingWith("{}", "search_");
		return taskTableService.findListEQStatusByFilter(XaConstant.Status.valid, filterParams, pageable);
	}
}

